
import javax.swing.JOptionPane;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author anderzanic
 */
public class PalavraSecreta extends javax.swing.JDialog {

    private static Jogo jogo = null;
    private static Login login;
    /**
     * Creates new form PalavraSecreta
     */
    public PalavraSecreta(java.awt.Frame login, boolean modal, Jogo jogo) {
        super(login, modal);
        this.jogo = jogo;
        this.login = (Login) login;
        this.setLocationRelativeTo(null);
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblPalavra = new javax.swing.JLabel();
        txtPalavra = new javax.swing.JTextField();
        lblDica = new javax.swing.JLabel();
        txtDica = new javax.swing.JTextField();
        btnOk = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Palavra Secreta");
        setMaximumSize(new java.awt.Dimension(420, 210));
        setMinimumSize(new java.awt.Dimension(420, 210));
        getContentPane().setLayout(null);

        lblPalavra.setText("Palavra Secreta:");
        getContentPane().add(lblPalavra);
        lblPalavra.setBounds(22, 20, 111, 17);
        getContentPane().add(txtPalavra);
        txtPalavra.setBounds(22, 43, 367, 27);

        lblDica.setText("Dica:");
        getContentPane().add(lblDica);
        lblDica.setBounds(24, 82, 34, 17);
        getContentPane().add(txtDica);
        txtDica.setBounds(24, 105, 365, 27);

        btnOk.setText("OK");
        btnOk.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOkActionPerformed(evt);
            }
        });
        getContentPane().add(btnOk);
        btnOk.setBounds(340, 140, 50, 29);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
        if(!txtPalavra.getText().equals("") && !txtDica.getText().equals("")) {
            jogo.setPalavra(txtPalavra.getText());
            jogo.setDica(txtDica.getText());
            close();
        } else {
            JOptionPane.showMessageDialog(this, "Informe a palavra e a dica!");
        }
    }//GEN-LAST:event_btnOkActionPerformed

    public void close() {
        dispose();
    }
    /**
     * @param args the command line arguments
     */
//    public static void main(String args[]) {
//        /* Set the Nimbus look and feel */
//        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
//        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
//         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
//         */
//        try {
//            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
//                if ("Nimbus".equals(info.getName())) {
//                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
//                    break;
//                }
//            }
//        } catch (ClassNotFoundException ex) {
//            java.util.logging.Logger.getLogger(PalavraSecreta.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (InstantiationException ex) {
//            java.util.logging.Logger.getLogger(PalavraSecreta.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (IllegalAccessException ex) {
//            java.util.logging.Logger.getLogger(PalavraSecreta.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
//            java.util.logging.Logger.getLogger(PalavraSecreta.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        }
//        //</editor-fold>
//
//        /* Create and display the dialog */
//        java.awt.EventQueue.invokeLater(new Runnable() {
//            public void run() {
//                PalavraSecreta dialog = new PalavraSecreta(new javax.swing.JFrame(), true);
//                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
//                    @Override
//                    public void windowClosing(java.awt.event.WindowEvent e) {
//                        System.exit(0);
//                    }
//                });
//                dialog.setVisible(true);
//            }
//        });
//    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnOk;
    private javax.swing.JLabel lblDica;
    private javax.swing.JLabel lblPalavra;
    private javax.swing.JTextField txtDica;
    private javax.swing.JTextField txtPalavra;
    // End of variables declaration//GEN-END:variables
}
